package my.interview;

import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
public class Temp {



    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String result = getResult(str);
        System.out.println(result);
    }

    private static String getResult(String str) {
        String[] splitStr = str.split(" ");
        Arrays.sort(splitStr);
        TreeSet<String> treeSet = new TreeSet<>(Arrays.asList(splitStr));
        TreeSet<String> res = new TreeSet<>();
        for(int i= splitStr.length-1;i>=0;i--){
            String result = splitStr[i];
            String temp = result.substring(0, result.length() - 1);
            boolean flag = true;
            while (temp.length() > 0){
                if(flag = treeSet.contains(temp)){
                    temp = temp.substring(0,temp.length()-1);
                }else {
                    break;
                }
            }
            if(flag){
                res.add(result);
            }
        }
        if(res.size()>0){
            return res.last();
        }
        return "";
    }
}
